<template>
    <div>
        <el-button type="primary" size="small" style="margin-bottom: 10px" @click="toSave">保存</el-button>
        <el-container>
            <el-aside width="200px"><fixer-list ref="fixer-list" @getData="getData"></fixer-list></el-aside>
            <el-main><center-category ref="center-category" v-model="categoryList"></center-category></el-main>
            <el-main><right-address ref="right-address"  v-model="addressList"></right-address></el-main>
        </el-container>
    </div>
</template>
<script>
    import CenterCategory from "./components/CenterCategory";
    import RightAddress from "./components/RightAddress";
    import FixerList from "./components/FixerList";
    import fixer from "@/api/fixer/index"
    export default {
        name:"TabContainer",
        components: {FixerList, RightAddress, CenterCategory},
        data() {
            return {
                num: 1,
                categoryList:[],
                addressList:[]
            };
        },
        created() {
        },
        methods: {
            toSave(){
                let id = this.$refs["fixer-list"].getId()
                fixer.toEdit(id,{
                    "fix_category":this.$refs["center-category"].getCheckedList(),//维修分类id数组
                    "address": this.$refs["right-address"].getCheckedList()//地址id数组
                }).then(res=>{
                    this.msgSuccess(res.data.msg)
                })
            },
            getData(id){
                fixer.getFixerInfo(id).then(res=>{
                   this.categoryList = res.data.fix_category
                    this.addressList = res.data.address
                })
            }
        }
    };
</script>
<style lang="scss" scoped>
    .el-main{
        padding: 0px 20px;
    }
    .el-aside{
        padding: 0px;
    }
</style>
